/*
 * ===========================================================================
 *
 *      Filename: stack.c
 *   Description: stack operation
 *        Author: Ye wenhao, wenhaoye@126.com
 *  Organization: 
 *
 * ===========================================================================
 */
#include "stack.h"

stack_t *stack_create(uint32_t size, locker_t *locker)
{
    stack_t *self = darray_create(size, locker);
    return self;
}

void stack_destroy(stack_t **p_self, darray_item_destroy_func destroy)
{
    return darray_destroy(p_self, destroy);
}

int stack_push(stack_t *self, void *data)
{
    return darray_insert_tail(self, data);
}

void *stack_pop(stack_t *self)
{
    void *data = NULL;
    if(darray_remove_tail(self, &data) < 0)
        return NULL;
    else
        return data;
}

void *stack_top(stack_t *self)
{
   return darray_get_tail(self); 
}

uint32_t stack_nums(stack_t *self)
{
    return darray_nums(self);
}
